//判断sessionStorage对象中是否有user对象
var userStr = sessionStorage.getItem("user");
var user;
if(userStr){//如果有登录,就转为json对象
    user = JSON.parse(userStr);
}else{
    window.location.href="/login.html";
}